//
//  ZPCallAlertView.m
//  ZPIOSEducation
//
//  Created by mini1 on 2016/12/30.
//  Copyright © 2016年 mini1. All rights reserved.
//

#import "ZPCallAlertView.h"
@interface ZPCallAlertView ()

@property (weak, nonatomic) IBOutlet UIView   *topView;
@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;
@property (weak, nonatomic) IBOutlet UIButton *phoneBtn;
@end

@implementation ZPCallAlertView

- (void)awakeFromNib
{
    [super awakeFromNib];
    _phoneView.userInteractionEnabled = YES;
    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cancelBtnClick:)];
    [_phoneView addGestureRecognizer:gesture];
}
- (void)setStatus
{
    NSTimeInterval currentInterval = [[NSDate date] timeIntervalSince1970];
    NSString *currentTime = [NSDate timeHourStringWithInterval:currentInterval];
    if ([currentTime integerValue] < 9 || [currentTime integerValue] >= 22) {
        NSMutableAttributedString *muAtrStr = [[NSMutableAttributedString alloc] initWithString:@"拨打 025-58115681"];
        NSAttributedString *atrStr = [[NSMutableAttributedString alloc] initWithString:@"\n       (周一至周日 9:00~22:00)" attributes:@{NSFontAttributeName : Z12} ];
        [muAtrStr appendAttributedString:atrStr];
        [muAtrStr addAttribute:NSForegroundColorAttributeName value:RGBCOLOR(153, 153, 153) range:NSMakeRange(0, muAtrStr.length)];
        [self.phoneBtn setAttributedTitle:muAtrStr forState:UIControlStateNormal];
    } else {
        NSMutableAttributedString *muAtrStr = [[NSMutableAttributedString alloc]initWithString:@"拨打 025-58115681"];
        [muAtrStr addAttribute:NSForegroundColorAttributeName value:RGBCOLOR(255, 59, 48) range:NSMakeRange(0,muAtrStr.length)];
        [self.phoneBtn setAttributedTitle:muAtrStr forState:UIControlStateNormal];
    }
}


- (IBAction)phoneBtnClick:(id)sender
{
    self.call();
}
- (IBAction)cancelBtnClick:(id)sender
{
    self.cancel();
}

@end
